package com.hiabr.iep.common.domain.po;

import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableLogic;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.Date;

/**
 * description: BaseEntity
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
public class BaseEntity {

//    private static final long serialVersionUID = 5663975977550116965L;

    //主键
    @TableId
    private Long id;
    @TableLogic
    private Integer deleted;
    //创建人
    @TableField(fill = FieldFill.INSERT)
    private Long createBy;
    //创建时间
    @TableField(fill = FieldFill.INSERT)
    private Date createTime;
    //更新人
    @TableField(fill = FieldFill.INSERT_UPDATE)
    private Long updateBy;
    //更新时间
    @TableField(fill = FieldFill.INSERT_UPDATE)
    private Date updateTime;

    /**
     * 新增时使用
     */
    public void setCreateCommon() {
//        BaseUserReq user = ThreadLocalContext.getUser();
//        Long userId = user == null ? 0 : user.getUserId();
//        Date now = new Date();
//        this.deleted = 0;
//        this.createBy = userId;
//        this.createTime = now;
//        this.updateBy = userId;
//        this.updateTime = now;
    }

    /**
     * 修改时使用
     */
    public void setUpdateCommon() {
//        BaseUserReq user = ThreadLocalContext.getUser();
//        this.updateBy = user == null ? 0L : user.getUserId();
    }
}
